function ChangeRowState(el){
    if (el.tagName.toLowerCase() != "tr")return;
    var depthString = el.getAttribute("__depth");
    if (depthString == null)return;
    var depth = parseInt(depthString);
    var start = el.rowIndex;
    var table = $P(el,"table");
    var state = GetRowState(el);
    var tempstate = "";
    for(var i = start + 1; i < table.rows.length; i ++){
        var row = table.rows[i];
        if (row == null)break;
        var curDepth = row.getAttribute("__depth");
        if (curDepth == depth)break;
        if (state == "expand"){
			if (curDepth > depth){
				row.style.display = "none";            
			}
        }else{
			if (curDepth == depth + 1){
				tempstate = GetRowState(row);
				row.style.display = "";
			}else if (curDepth > depth + 1){
				if (tempstate == "collapse"){
					row.style.display = "none";
				}else{
					row.style.display = "";
				}
			}
        }
    }
    state = state == "expand" ? "collapse" : "expand";
    el.setAttribute("__state",state);
}
function GetRowState(el){
	var state = el.getAttribute("__state");
	if (state == null){
		state = "expand";
	}
    return state;
}